Skip to content

gh-82113: Fix ConfigParser.items() returning '' for value-less options#151898

Open
iamsharduld wants to merge 1 commit into
python:mainfrom
iamsharduld:local-gh-82113-configparser-items-none
Open

gh-82113: Fix ConfigParser.items() returning '' for value-less options#151898
iamsharduld wants to merge 1 commit into
python:mainfrom
iamsharduld:local-gh-82113-configparser-items-none

Conversation

@iamsharduld

@iamsharduld iamsharduld commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

With allow_no_value=True, a value-less option is stored as None.
ConfigParser.get() returns it directly (if raw or value is None: return value), and mapping access and dict(section) also return None. But
items(section) always ran each value through
self._interpolation.before_get(), which turns None into an empty string, so
items() was inconsistent with every other accessor.

Make the non-raw value getter in items() mirror get(): return the stored
value directly when it is None, otherwise interpolate. Interpolation of real
values is unchanged.

…options

ConfigParser.items() always ran the option value through interpolation,
which turned a None value (a value-less option under allow_no_value=True)
into an empty string. get(), mapping access and dict(section) all return
None in that case. Skip interpolation when the stored value is None so
items() is consistent with the other accessors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant